USE [notarial]
GO

/****** Object:  Table [dbo].[NotarialFormHistory]    Script Date: 01/11/2012 05:21:41 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[NotarialFormHistory](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](50) NULL,
	[OrderId] [int] NULL,
	[StatusId] [int] NULL,
	[RangeId] [int] NULL,
	[SerialNumberId] [int] NULL,
	[CreateDate] [datetime] NULL,
	[EndDate] [datetime] NULL,
	[IsInAct] [bit] NULL,
	[IsInEnot] [bit] NULL,
	[UserId] [int] NOT NULL,
	[Date] [datetime] NOT NULL,
	[NotarialFormId] [int] NULL,
	[IsDeleted] [bit] NOT NULL,
	[Comment] [nchar](1000) NULL,
 CONSTRAINT [PK_NotarialFormHistory] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[NotarialFormHistory]  WITH CHECK ADD  CONSTRAINT [FK_NotarialFormHistory_NotarialForm] FOREIGN KEY([NotarialFormId])
REFERENCES [dbo].[NotarialForm] ([Id])
ON UPDATE CASCADE
ON DELETE CASCADE
GO

ALTER TABLE [dbo].[NotarialFormHistory] CHECK CONSTRAINT [FK_NotarialFormHistory_NotarialForm]
GO

ALTER TABLE [dbo].[NotarialFormHistory]  WITH CHECK ADD  CONSTRAINT [FK_NotarialFormHistory_User] FOREIGN KEY([UserId])
REFERENCES [dbo].[User] ([Id])
GO

ALTER TABLE [dbo].[NotarialFormHistory] CHECK CONSTRAINT [FK_NotarialFormHistory_User]
GO

ALTER TABLE [dbo].[NotarialFormHistory] ADD  CONSTRAINT [DF_NotarialFormHistory_Date]  DEFAULT (getdate()) FOR [Date]
GO

ALTER TABLE [dbo].[NotarialFormHistory] ADD  CONSTRAINT [DF_NotarialFormHistory_IsDeleted]  DEFAULT ((0)) FOR [IsDeleted]
GO

